<template>
  <a-modal v-model="visible" title="移至公海" :confirm-loading="confirmLoading" @ok="handleOk" @cancel="$emit('update:visible', false)">
    <a-textarea v-model="value" placeholder="请输入原因 (不得超过100字)" :maxLength="100" :auto-size="{ minRows: 5, maxRows: 5 }" />
  </a-modal>
</template>

<script>
import { putCrmCustomerInfos } from "./api";
export default {
  props: {
    visible: {
      type: Boolean,
      default: false
    },
    id: {
      type: String,
      default: ""
    }
  },
  watch: {
    visible(v) {
      if (v) this.value = "";
    }
  },
  data() {
    return {
      confirmLoading: false,
      value: ""
    };
  },
  methods: {
    async handleOk() {
      try {
        await putCrmCustomerInfos({
          id: this.id,
          isPublic: true,
          removeReason: this.value
        });
        this.$notification.success({ message: "操作成功" });
        this.$emit("update:visible", false);
        this.$emit("upDate");
      } catch (err) {
        console.log("error log --> ", err);
      }
    }
  }
};
</script>

<style lang="scss" scoped></style>
